﻿
module Modal
{

	export class Wait
	{
		public modal: JQuery;

		public init(message: string = "Loading...")
		{
			this.modal = $('#waitModal');

			$('#waitmessage').html(message);
		}

		public show(): void
		{
			this.modal["foundation"]('reveal', 'open');
		}

		public hide(): void
		{
			this.modal["foundation"]('reveal', 'close');
		}


	}

	export class Error
	{
		public modal: JQuery;

		public changeMessage(message:string)
		{
			$('#errormessage').html(message);
		}

		public init(message: string = "Có lỗi xảy ra")
		{
			this.modal = $('#errorModal');
			$('#errormessage').html(message);
		
		}

		public show(): void
		{
		
			this.modal["foundation"]('reveal', 'open');
		}

		public hide(): void
		{
	
			this.modal["foundation"]('reveal', 'close');
		}

	}

	

	export class Confirm
	{
		public onOK() { }
		public onCancel() { }

		private modal: JQuery;


		public init()
		{
			var thethis = this;

			this.modal  = $('<div id="confirmModal" class="reveal-modal small" data-reveal><div class="row" style = "text-align: center;"><h4 id = "confirmmessage">Bạn có chắc chắn không ?</h4><a class="okbutton button error"></a><a class="cancelbutton button success"></a></div></div >');
			$('body').append(this.modal);
			this.modal['foundation']();
			this.modal.find('.okbutton')[0].onclick = function ()
			{
				thethis.hide();
				thethis.onOK();

			}

			this.modal.find('.cancelbutton')[0].onclick = function ()
			{
				thethis.hide();
				thethis.onCancel();

			}


		}

		public show(): void
		{
			this.modal["foundation"]('reveal', 'open');
		}

		public hide(): void
		{
			this.modal["foundation"]('reveal', 'close');
		}



	}

}
